package com.imooc.socketexample;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务端Socket
 */
public class ServerSocketTest {

    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(8888);
            System.out.println("链接服务器正在启动：");
            int count=0;
            while (true){
                Socket socket = serverSocket.accept();
                ServerThread serverThread = new ServerThread(socket);
                serverThread.start();
                count++;
                System.out.println("已连接"+count+"个客户端");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
